package utils

import (
	"github.com/gin-gonic/gin"
	"github.com/google/uuid"
	"go.uber.org/zap"
)

func UnknownError(ctx *gin.Context) zap.Field {
	id := uuid.NewString()
	ctx.JSON(200, gin.H{
		"code":       500,
		"msg":        "unknown error occurred, please try again later!",
		"request_id": id,
	})
	return zap.String("request_id", id)
}

func BadRequest(ctx *gin.Context, message string) {
	ctx.JSON(200, gin.H{
		"code": 400,
		"msg":  message,
	})
}

func Success(ctx *gin.Context, message string, data interface{}) {
	ctx.JSON(200, gin.H{
		"code": 200,
		"data": data,
		"msg":  message,
	})
}

func serverResponse(ctx *gin.Context, code int, data interface{}, message string) {
	ctx.JSON(200, gin.H{
		"code": code,
		"data": data,
		"msg":  message,
	})
}
